﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WebManager;

namespace BaoJian.e
{
    public partial class channel : System.Web.UI.Page
    {
        private string ColumnID = null;
        public string ColumnName = null;
        private string TID = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            ColumnID = HttpContext.Current.Request.QueryString["cid"];
            TID = HttpContext.Current.Request.QueryString["tid"];
            if (!Page.IsPostBack)
            {
                ColumnName = Tools.Common.ColumnName(ColumnID, "1");
                BindData();
            }
        }

        private void BindData()
        {
            string sql = null;
            if (TID == "1")
            {
                sql = "([PCatalog1]=''{0}'' OR [PCatalog2] = ''{0}'' OR [PCatalog3] =''{0}''  OR [PCatalog4]=''{0}'')";
                sql = string.Format(sql, ColumnID);
                using (DataSet ds = Tools.Common.GetPage("EProduct", "SID,PID,NAME,[ImagePath],[Price],[MarketPrice],[Discount],[Available]", "SID", AspNetPager.PageSize,
                     AspNetPager.CurrentPageIndex, false, true,sql, "PID"))
                {
                    List1.DataSource = ds.Tables[0].DefaultView;
                    List1.DataBind();

                    DataSet ds1 = Tools.Common.GetPage("EProduct", "SID,PID,NAME,[ImagePath],[Price],[MarketPrice].[Available]", "SID", AspNetPager.PageSize,
                     AspNetPager.CurrentPageIndex, true, true, sql, "PID");
                    AspNetPager.RecordCount = Convert.ToInt32(ds1.Tables[0].Rows[0][0]);
                }
            }
            else if(TID == "2")
            {
            }

     

        }

        protected void AspNetPager_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

     



    }
}
